package com.gel.aiagent.agent;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.model.tool.ToolCallingManager;
import org.springframework.ai.tool.ToolCallback;

/*ReAct模式的代理抽象类
* 实现了思考-行动的循环模式*/
@EqualsAndHashCode(callSuper = true)
@Data
@Slf4j
public abstract class ReActAgent extends BaseAgent{


    /*处理当前状态决定是否下一步行动*/
    public abstract boolean think();

    /*执行决定的行动*/
    public abstract String act();

    @Override
    public String step(){
        try {
            boolean shouldAct=think();
            if(!shouldAct){
                return "思考完成-无需行动";
            }
            return act();
        } catch (Exception e) {
            e.printStackTrace();
            return "步骤执行失败："+e.getMessage();
        }
    }

}
